testrunner.define({
  
  classname : "target",
  testee    : null,
  calls     : null,

  
  setUp : function()
  {
    this.testee = new lesp.Target(["foo", "bar"]);
    this.calls  = 0;
  },
  
  fixture : function()
  {
    this.calls += 1;
  },
  
  testAttach : function()
  {
    this.testee.attach("foo", this.fixture.bind(this));
    this.testee.notify("foo", 123);
    this.assertEquals(1, this.calls);
    
    this.assertEquals(1, this.testee._listeners.foo.length);
    this.assertEquals(0, this.testee._listeners.bar.length);
  },

  testDetach : function()
  {
    var handler = this.fixture.bind(this);
    this.testee.attach("bar", handler);
    this.testee.detach("bar", handler);
    
    this.testee.notify("foo", 123);
    this.assertEquals(0, this.calls);
    
    this.assertEquals(0, this.testee._listeners.foo.length);
    this.assertEquals(0, this.testee._listeners.bar.length);
  },
  
  testNotify : function()
  {
    this.testee.attach("foo", this.fixture.bind(this));
    this.testee.attach("bar", this.fixture.bind(this));
    this.testee.notify("foo", 123);
    this.testee.notify("bar", 321);
    this.assertEquals(2, this.calls);
    
    this.assertEquals(1, this.testee._listeners.foo.length);
    this.assertEquals(1, this.testee._listeners.bar.length);
  }
  
});